//
//  MessageNoteListCell.m
//  ShrimpCrowdordering
//
//  Created by 郑洲 on 2018/7/25.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "MessageNoteListCell.h"

@interface MessageNoteListCell ()

@property (nonatomic, strong) UIButton *noteView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *numLabel;

@end

@implementation MessageNoteListCell

+ (MessageNoteListCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"MessageNoteListCell";
    MessageNoteListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[MessageNoteListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.backgroundColor = TABLEVIEW_BACKGROUNDCOLOR;
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.noteView = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(17), ScreenX375(50), ScreenX375(50))];
    [self addSubview:self.noteView];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(78), ScreenX375(0), ScreenX375(150), ScreenX375(84))];
    self.titleLabel.textColor = REXADECIMALCOLOR(@"#222222");
    self.titleLabel.font = Kfont(14);
    [self addSubview:self.titleLabel];
    
    self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(49), ScreenX375(35), ScreenX375(14), ScreenX375(14))];
    self.numLabel.textColor = [UIColor whiteColor];
    self.numLabel.font = Kfont(9);
    self.numLabel.textAlignment = NSTextAlignmentCenter;
    self.numLabel.backgroundColor = REXADECIMALCOLOR(@"#f80000");
    self.numLabel.layer.cornerRadius = ScreenX375(7);
    self.numLabel.clipsToBounds = YES;
    [self addSubview:self.numLabel];
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(84) - 0.5, SCREEN_WIDTH - ScreenX375(32), 0.5)];
    line.backgroundColor = LineColor;
    [self addSubview:line];
}

- (void)initWithImageName:(NSString *)imageName andNoteName:(NSString *)noteName andNum:(NSString *)num {
    [self.noteView setImage:ImageWithName(imageName) forState:UIControlStateNormal];
    self.titleLabel.text = noteName;
    self.numLabel.text = num;
    if ([num integerValue] == 0) {
        self.numLabel.hidden = YES;
    }else {
        self.numLabel.hidden = NO;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
